package day4;

import java.io.File;
import java.io.IOException;

/**
 * ClassName：Test1
 *
 * @Author：小鱼
 * @Create：2025-08-21 9:12
 */
public class Test1 {
    public static void main(String[] args) throws IOException {
//        //方法一：
//        String pathName = " D:\\IDEA_project\\JP_Java\\week6\\src\\day4\\Test1.java";
//        File file1 = new File(pathName);
//        System.out.println("file1: "+file1);
//        //方法二
//        String parent = "D:\\IDEA_project\\JP_Java\\week6\\src";
//        String child = "day4\\Test1.java";
//        File file2 = new File(parent,child);
//        System.out.println("file2: "+file2);
//        //方法三：
//        File fileParent = new File(parent);
//        File file3 = new File(fileParent,child);
//        System.out.println("file3: "+file3);
//
//        File file4 = new File("C:\\Users\\ASUS\\Desktop");
//        File file5 = new File("D:\\IDEA_project\\JP_Java\\week6\\src\\day4\\Test1.java");
//        File file6 = new File("Test1.java");
//
//
//        System.out.println(file1.getName());
//        System.out.println(file1.getPath());
//        System.out.println(file1.getAbsolutePath());
//        System.out.println(file1.length());
//
//
//        System.out.println(file4.getName());
//        System.out.println(file4.getPath());
//        System.out.println(file4.getAbsolutePath());
//        System.out.println(file4.length());
//
//        System.out.println(file5.getPath());
//        System.out.println(file6.getPath());
//
//        System.out.println(file5.exists());
//        System.out.println(file6.exists());
//
//        System.out.println(file4.isDirectory());
//        System.out.println(file5.isFile());
//
//        System.out.println(file6.createNewFile());
//        System.out.println(file6.delete());
//
//        //创建目录
//        File file7 = new File("NewDir");
//        System.out.println(file7.mkdir());
//        System.out.println("目录的完整路径：" + file7.getAbsolutePath());

        File file10 = new File("D:\\IDEA_project\\JP_Java\\week6");
        File[] filesList = file10.listFiles();
        System.out.println(filesList.length);
//        for (int i = 0; i < filesList.length; i++) {
//            System.out.println(filesList[i]);
//        }
        for (File file:filesList) {
            System.out.println(file.getName());
        }

        String[] list = file10.list();
        for (String s:list) {
            System.out.println(s);
        }
    }
}
